Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default suggested links to pages #54622

Merged
merged 6 commits into from
Oct 2, 2023
Merged

Default suggested links to pages #54622

merged 6 commits into from
Oct 2, 2023

Conversation

draganescu
Copy link
Contributor

@draganescu draganescu commented Sep 19, 2023

What?

Closes #53904 - defaults suggestions in LinkUI to pages.

~~This change applies in all linking instances where linking UI shows suggestions, not only in the navigation block as the original issue asks.

I think this is good for consistency and also because the mixed suggestions seem less likely to be helpful.~~

Why?

Because most linking is either towards pages or external links. For taxonomy links or posts it is far more likely to need to filter by search term.

Pages are generally few in number and therefore it makes sense to always default to suggesting existing pages.

How?

This is how the suggestions are setup and shown in the navigation link block, part of the navigation block:

Untitled-2023-09-28-1158(1)

~~This exploration changes how the core data (!) fetchLinkSuggestions ... util? works. This currently searches through everything and tries to show something.

The change defaults to always showing pages if the call is for "initial suggestions" - which also means:

  • if there are no pages there are no suggestions
  • there will always be the same suggestions~~

The PR introduces a new member of the search options object that gets eventually used by fetchLinkSuggestions. This new initialSuggestionsSearchOptions member overrides all the options in searchOptions; for the initial suggestions.

The navigation link block now uses this to default to suggesting a max of 20 pages initially for the custom link variation.

Testing Instructions

  1. Make sure you have some published pages, then
  2. In a post
  3. Add a navigation block
  4. Notice when adding items the suggestions are only pages

Testing Instructions for Keyboard

N/A

Screenshots or screencast

page-suggestions-default.mp4

@github-actions
Copy link

github-actions bot commented Sep 19, 2023

Size Change: +569 B (0%)

Total Size: 1.62 MB

Filename Size Change
build/block-directory/index.min.js 7.07 kB +15 B (0%)
build/block-editor/index.min.js 218 kB +148 B (0%)
build/block-library/blocks/image/style-rtl.css 1.4 kB -18 B (-1%)
build/block-library/blocks/image/style.css 1.39 kB -18 B (-1%)
build/block-library/blocks/image/view.min.js 1.83 kB +2 B (0%)
build/block-library/blocks/navigation-link/style-rtl.css 103 B -12 B (-10%) 👏
build/block-library/blocks/navigation-link/style.css 103 B -12 B (-10%) 👏
build/block-library/index.min.js 207 kB +50 B (0%)
build/block-library/style-rtl.css 14 kB -16 B (0%)
build/block-library/style.css 14 kB -16 B (0%)
build/blocks/index.min.js 51.5 kB +7 B (0%)
build/commands/index.min.js 15.5 kB +6 B (0%)
build/components/index.min.js 248 kB +89 B (0%)
build/components/style-rtl.css 11.8 kB +8 B (0%)
build/components/style.css 11.8 kB +11 B (0%)
build/compose/index.min.js 12.7 kB +1 B (0%)
build/core-commands/index.min.js 2.72 kB +11 B (0%)
build/core-data/index.min.js 70.5 kB +58 B (0%)
build/customize-widgets/index.min.js 12 kB +11 B (0%)
build/data/index.min.js 8.78 kB -84 B (-1%)
build/edit-post/index.min.js 35.7 kB +29 B (0%)
build/edit-site/index.min.js 185 kB +75 B (0%)
build/edit-site/style-rtl.css 14 kB +37 B (0%)
build/edit-site/style.css 14 kB +38 B (0%)
build/edit-widgets/index.min.js 17 kB +18 B (0%)
build/editor/index.min.js 45.9 kB +10 B (0%)
build/format-library/index.min.js 7.79 kB +13 B (0%)
build/keyboard-shortcuts/index.min.js 1.76 kB +13 B (+1%)
build/list-reusable-blocks/index.min.js 2.21 kB +11 B (0%)
build/nux/index.min.js 2.01 kB +8 B (0%)
build/patterns/index.min.js 3.57 kB +8 B (0%)
build/plugins/index.min.js 1.81 kB +8 B (0%)
build/preferences/index.min.js 1.26 kB +3 B (0%)
build/react-i18n/index.min.js 631 B +7 B (+1%)
build/reusable-blocks/index.min.js 2.73 kB +9 B (0%)
build/rich-text/index.min.js 10.2 kB +14 B (0%)
build/router/index.min.js 1.79 kB +8 B (0%)
build/server-side-render/index.min.js 1.96 kB +11 B (+1%)
build/viewport/index.min.js 967 B -1 B (0%)
build/widgets/index.min.js 7.18 kB +9 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 964 B
build/annotations/index.min.js 2.71 kB
build/api-fetch/index.min.js 2.29 kB
build/autop/index.min.js 2.11 kB
build/blob/index.min.js 461 B
build/block-directory/style-rtl.css 1.04 kB
build/block-directory/style.css 1.04 kB
build/block-editor/content-rtl.css 4.28 kB
build/block-editor/content.css 4.27 kB
build/block-editor/default-editor-styles-rtl.css 403 B
build/block-editor/default-editor-styles.css 403 B
build/block-editor/style-rtl.css 15.6 kB
build/block-editor/style.css 15.6 kB
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 150 B
build/block-library/blocks/audio/editor.css 150 B
build/block-library/blocks/audio/style-rtl.css 122 B
build/block-library/blocks/audio/style.css 122 B
build/block-library/blocks/audio/theme-rtl.css 138 B
build/block-library/blocks/audio/theme.css 138 B
build/block-library/blocks/avatar/editor-rtl.css 116 B
build/block-library/blocks/avatar/editor.css 116 B
build/block-library/blocks/avatar/style-rtl.css 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/block/editor-rtl.css 305 B
build/block-library/blocks/block/editor.css 305 B
build/block-library/blocks/button/editor-rtl.css 587 B
build/block-library/blocks/button/editor.css 587 B
build/block-library/blocks/button/style-rtl.css 633 B
build/block-library/blocks/button/style.css 632 B
build/block-library/blocks/buttons/editor-rtl.css 337 B
build/block-library/blocks/buttons/editor.css 337 B
build/block-library/blocks/buttons/style-rtl.css 332 B
build/block-library/blocks/buttons/style.css 332 B
build/block-library/blocks/calendar/style-rtl.css 239 B
build/block-library/blocks/calendar/style.css 239 B
build/block-library/blocks/categories/editor-rtl.css 113 B
build/block-library/blocks/categories/editor.css 112 B
build/block-library/blocks/categories/style-rtl.css 124 B
build/block-library/blocks/categories/style.css 124 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 421 B
build/block-library/blocks/columns/style.css 421 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-content/style-rtl.css 92 B
build/block-library/blocks/comment-content/style.css 92 B
build/block-library/blocks/comment-template/style-rtl.css 199 B
build/block-library/blocks/comment-template/style.css 198 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 840 B
build/block-library/blocks/comments/editor.css 839 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 636 B
build/block-library/blocks/cover/editor-rtl.css 647 B
build/block-library/blocks/cover/editor.css 650 B
build/block-library/blocks/cover/style-rtl.css 1.7 kB
build/block-library/blocks/cover/style.css 1.69 kB
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 98 B
build/block-library/blocks/details/style.css 98 B
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/embed/theme-rtl.css 138 B
build/block-library/blocks/embed/theme.css 138 B
build/block-library/blocks/file/editor-rtl.css 316 B
build/block-library/blocks/file/editor.css 316 B
build/block-library/blocks/file/style-rtl.css 311 B
build/block-library/blocks/file/style.css 312 B
build/block-library/blocks/file/view.min.js 321 B
build/block-library/blocks/footnotes/style-rtl.css 201 B
build/block-library/blocks/footnotes/style.css 199 B
build/block-library/blocks/freeform/editor-rtl.css 2.61 kB
build/block-library/blocks/freeform/editor.css 2.61 kB
build/block-library/blocks/gallery/editor-rtl.css 957 B
build/block-library/blocks/gallery/editor.css 962 B
build/block-library/blocks/gallery/style-rtl.css 1.55 kB
build/block-library/blocks/gallery/style.css 1.55 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 654 B
build/block-library/blocks/group/editor.css 654 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 189 B
build/block-library/blocks/heading/style.css 189 B
build/block-library/blocks/html/editor-rtl.css 340 B
build/block-library/blocks/html/editor.css 341 B
build/block-library/blocks/image/editor-rtl.css 834 B
build/block-library/blocks/image/editor.css 833 B
build/block-library/blocks/image/theme-rtl.css 137 B
build/block-library/blocks/image/theme.css 137 B
build/block-library/blocks/latest-comments/style-rtl.css 357 B
build/block-library/blocks/latest-comments/style.css 357 B
build/block-library/blocks/latest-posts/editor-rtl.css 213 B
build/block-library/blocks/latest-posts/editor.css 212 B
build/block-library/blocks/latest-posts/style-rtl.css 478 B
build/block-library/blocks/latest-posts/style.css 478 B
build/block-library/blocks/list/style-rtl.css 88 B
build/block-library/blocks/list/style.css 88 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 505 B
build/block-library/blocks/media-text/style.css 503 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 671 B
build/block-library/blocks/navigation-link/editor.css 672 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation/editor-rtl.css 2.26 kB
build/block-library/blocks/navigation/editor.css 2.26 kB
build/block-library/blocks/navigation/style-rtl.css 2.26 kB
build/block-library/blocks/navigation/style.css 2.25 kB
build/block-library/blocks/navigation/view.min.js 1.01 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 401 B
build/block-library/blocks/page-list/editor.css 401 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 235 B
build/block-library/blocks/paragraph/editor.css 235 B
build/block-library/blocks/paragraph/style-rtl.css 335 B
build/block-library/blocks/paragraph/style.css 335 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 508 B
build/block-library/blocks/post-comments-form/style.css 508 B
build/block-library/blocks/post-date/style-rtl.css 61 B
build/block-library/blocks/post-date/style.css 61 B
build/block-library/blocks/post-excerpt/editor-rtl.css 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 141 B
build/block-library/blocks/post-excerpt/style.css 141 B
build/block-library/blocks/post-featured-image/editor-rtl.css 588 B
build/block-library/blocks/post-featured-image/editor.css 586 B
build/block-library/blocks/post-featured-image/style-rtl.css 322 B
build/block-library/blocks/post-featured-image/style.css 322 B
build/block-library/blocks/post-navigation-link/style-rtl.css 215 B
build/block-library/blocks/post-navigation-link/style.css 214 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 314 B
build/block-library/blocks/post-template/style.css 314 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-time-to-read/style-rtl.css 69 B
build/block-library/blocks/post-time-to-read/style.css 69 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 B
build/block-library/blocks/preformatted/style-rtl.css 125 B
build/block-library/blocks/preformatted/style.css 125 B
build/block-library/blocks/pullquote/editor-rtl.css 135 B
build/block-library/blocks/pullquote/editor.css 135 B
build/block-library/blocks/pullquote/style-rtl.css 335 B
build/block-library/blocks/pullquote/style.css 335 B
build/block-library/blocks/pullquote/theme-rtl.css 168 B
build/block-library/blocks/pullquote/theme.css 168 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 288 B
build/block-library/blocks/query-pagination/style.css 284 B
build/block-library/blocks/query-title/style-rtl.css 63 B
build/block-library/blocks/query-title/style.css 63 B
build/block-library/blocks/query/editor-rtl.css 486 B
build/block-library/blocks/query/editor.css 486 B
build/block-library/blocks/query/style-rtl.css 375 B
build/block-library/blocks/query/style.css 372 B
build/block-library/blocks/query/view.min.js 609 B
build/block-library/blocks/quote/style-rtl.css 222 B
build/block-library/blocks/quote/style.css 222 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/read-more/style-rtl.css 132 B
build/block-library/blocks/read-more/style.css 132 B
build/block-library/blocks/rss/editor-rtl.css 149 B
build/block-library/blocks/rss/editor.css 149 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 184 B
build/block-library/blocks/search/editor.css 184 B
build/block-library/blocks/search/style-rtl.css 613 B
build/block-library/blocks/search/style.css 613 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/search/view.min.js 471 B
build/block-library/blocks/separator/editor-rtl.css 146 B
build/block-library/blocks/separator/editor.css 146 B
build/block-library/blocks/separator/style-rtl.css 234 B
build/block-library/blocks/separator/style.css 234 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 329 B
build/block-library/blocks/shortcode/editor.css 329 B
build/block-library/blocks/site-logo/editor-rtl.css 760 B
build/block-library/blocks/site-logo/editor.css 760 B
build/block-library/blocks/site-logo/style-rtl.css 204 B
build/block-library/blocks/site-logo/style.css 204 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 116 B
build/block-library/blocks/site-title/editor.css 116 B
build/block-library/blocks/site-title/style-rtl.css 57 B
build/block-library/blocks/site-title/style.css 57 B
build/block-library/blocks/social-link/editor-rtl.css 184 B
build/block-library/blocks/social-link/editor.css 184 B
build/block-library/blocks/social-links/editor-rtl.css 682 B
build/block-library/blocks/social-links/editor.css 681 B
build/block-library/blocks/social-links/style-rtl.css 1.45 kB
build/block-library/blocks/social-links/style.css 1.45 kB
build/block-library/blocks/spacer/editor-rtl.css 359 B
build/block-library/blocks/spacer/editor.css 359 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 432 B
build/block-library/blocks/table/editor.css 432 B
build/block-library/blocks/table/style-rtl.css 646 B
build/block-library/blocks/table/style.css 645 B
build/block-library/blocks/table/theme-rtl.css 157 B
build/block-library/blocks/table/theme.css 157 B
build/block-library/blocks/tag-cloud/style-rtl.css 251 B
build/block-library/blocks/tag-cloud/style.css 253 B
build/block-library/blocks/template-part/editor-rtl.css 403 B
build/block-library/blocks/template-part/editor.css 403 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/term-description/style-rtl.css 111 B
build/block-library/blocks/term-description/style.css 111 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 99 B
build/block-library/blocks/verse/style.css 99 B
build/block-library/blocks/video/editor-rtl.css 552 B
build/block-library/blocks/video/editor.css 555 B
build/block-library/blocks/video/style-rtl.css 191 B
build/block-library/blocks/video/style.css 191 B
build/block-library/blocks/video/theme-rtl.css 139 B
build/block-library/blocks/video/theme.css 139 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.11 kB
build/block-library/common.css 1.11 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 12.2 kB
build/block-library/editor.css 12.2 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/reset-rtl.css 472 B
build/block-library/reset.css 472 B
build/block-library/theme-rtl.css 700 B
build/block-library/theme.css 705 B
build/block-serialization-default-parser/index.min.js 1.13 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/commands/style-rtl.css 947 B
build/commands/style.css 942 B
build/customize-widgets/style-rtl.css 1.51 kB
build/customize-widgets/style.css 1.5 kB
build/data-controls/index.min.js 651 B
build/date/index.min.js 17.9 kB
build/deprecated/index.min.js 462 B
build/dom-ready/index.min.js 336 B
build/dom/index.min.js 4.68 kB
build/edit-post/classic-rtl.css 571 B
build/edit-post/classic.css 571 B
build/edit-post/style-rtl.css 7.92 kB
build/edit-post/style.css 7.91 kB
build/edit-widgets/style-rtl.css 4.84 kB
build/edit-widgets/style.css 4.84 kB
build/editor/style-rtl.css 3.58 kB
build/editor/style.css 3.58 kB
build/element/index.min.js 4.87 kB
build/escape-html/index.min.js 548 B
build/format-library/style-rtl.css 577 B
build/format-library/style.css 577 B
build/hooks/index.min.js 1.57 kB
build/html-entities/index.min.js 454 B
build/i18n/index.min.js 3.61 kB
build/interactivity/index.min.js 11.4 kB
build/is-shallow-equal/index.min.js 535 B
build/keycodes/index.min.js 1.9 kB
build/list-reusable-blocks/style-rtl.css 865 B
build/list-reusable-blocks/style.css 865 B
build/media-utils/index.min.js 2.92 kB
build/notices/index.min.js 964 B
build/nux/style-rtl.css 775 B
build/nux/style.css 771 B
build/patterns/style-rtl.css 325 B
build/patterns/style.css 325 B
build/preferences-persistence/index.min.js 1.85 kB
build/primitives/index.min.js 994 B
build/priority-queue/index.min.js 1.52 kB
build/private-apis/index.min.js 972 B
build/react-refresh-entry/index.min.js 9.46 kB
build/react-refresh-runtime/index.min.js 6.78 kB
build/redux-routine/index.min.js 2.71 kB
build/reusable-blocks/style-rtl.css 265 B
build/reusable-blocks/style.css 265 B
build/shortcode/index.min.js 1.4 kB
build/style-engine/index.min.js 1.98 kB
build/token-list/index.min.js 587 B
build/url/index.min.js 3.84 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 41.8 kB
build/vendors/react.min.js 4.02 kB
build/warning/index.min.js 259 B
build/widgets/style-rtl.css 1.18 kB
build/widgets/style.css 1.18 kB
build/wordcount/index.min.js 1.03 kB

compressed-size-action

@draganescu draganescu added [Type] Enhancement A suggestion for improvement. Needs Design Feedback Needs general design feedback. [Block] Navigation Affects the Navigation Block [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) labels Sep 19, 2023
@draganescu draganescu marked this pull request as ready for review September 19, 2023 20:16
@draganescu draganescu requested a review from nerrad as a code owner September 19, 2023 20:16
@draganescu
Copy link
Contributor Author

I found it very surprising the depth of where this change had to be made, I expected this to be changed either in the consumer (e.g. navigation block) or in the component (LinkControl, LinkUI, search something) - but it was all the way down in core data.

I think this is from a time when things were simpler and pherhaps today we could bring the "concerns" more together.

@jasmussen
Copy link
Contributor

Very nice! Seems like it just needs a code review, this'll be good so we don't see recently uploaded fonts suggested here 😅 Thanks Andrei.

Almost certainly separate, but I would love for a next step to be showing these pages hierarchically and scrolling, i.e. a tree view so you can see the structure of your site rather than the most recent n pages. This is mentioned in the main tracking issues and is relevant mainly because pages are, arguably, mostly things you publish initially and once, and then they stay static for a long time. To that end, if we only show the most recent pages, you'll in most cases always see the same suggestions.

@getdave getdave requested a review from richtabor September 20, 2023 07:53
@getdave
Copy link
Contributor

getdave commented Sep 20, 2023

I think this is from a time when things were simpler and pherhaps today we could bring the "concerns" more together.

LinkControl is a standalone component in the block-editor package and so shouldn't really be aware of any WordPress specific data types.

It exposes APIs which you can hook into which allow you to define the search handler it uses when looking up suggestions. For WordPress specific use that handler is in Core Data.

I'm not sure we can bring the concerns closer together but I'm interested in any suggestions - perhaps in a dedicated Issue?

Copy link
Contributor

@getdave getdave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR. I agree with the goal to prioritise the most appropriate content type. However I have some concerns relating to how this will impact beyond the Core implementation so I'm raising a blocking review to avoid this landing for now...

Let's discuss further. Thanks 🙇

defaults suggestions in LinkUI to pages.

Forgive me but I don't think this is actually what is being achieved by this PR. The modification is to make the initial default search suggestions shown by the control on render prioritise Pages.

See screencapture below which shows the behaviour I describe above:

Screen.Capture.on.2023-09-20.at.11-31-47.mp4

That seems to be different from the stated goal of the PR but please let me know if I'm wrong.

queries.push(
apiFetch( {
path: addQueryArgs( '/wp/v2/search', {
search,
page,
per_page: perPage,
type: 'post',
subtype,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As state in the PR description this is a change across WP Core in how default links behave. This also applies to any 3rd party consumers of the component which utilise the fetchLinkSuggestions function from @wordpress/core.

Now all initial suggestions are forced to Page. There may be consumers of this component for whom that change is not what they wish and I believe it represents a potentially breaking change.

We should be absolutely certain this is what we want for all consumers before we merge this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with the way current initial suggestions work is that they are not meaningful. It would be an enhancement in terms of UX if the initial suggestions would always list pages. Ideally the initial suggestion query should be open to 3rd parties so they can fit their needs.

As it is now we show "a bit of everything" which doesn't really serve any purspose.

@getdave
Copy link
Contributor

getdave commented Sep 20, 2023

this'll be good so we don't see recently uploaded fonts suggested here

Do we have an Issue tracking this problem? I'd like to replicate in order that I can address this.

@draganescu
Copy link
Contributor Author

@getdave thanks for checking this out. I think this is what we want at least as a first step:

  • when the link UI opens the default suggestions are the pages, and only the pages a user has.

I think what I call default you call initial.

Later we should want to improve this even further and achieve something like this - a visual tree of the page hierarchy - as the 1st step when creating a link that has suggestions.

It is still unknown what should happen for a website which has no pages or one page, because the website uses custom post types or simply just posts exclusively. What do you think @jasmussen , should we keep the current behavior if there are no/too few pages?


Do we have an Issue tracking this [ see recently uploaded fonts suggested ] problem?

Check this out from Joen's previous issue.


Now all initial suggestions are forced to Page. ...I believe it represents a potentially breaking change.

Yes. That is true. It makes me think that the initial (default) suggestions should be controlled at the block level and we should not rely on a public API for this so we can cutomize the UX without having to cater to 3rd party contracts.

So I should not change the fetching core data suggestions and instead add fetching in the navigation block, whay do you think @getdave ?

@richtabor
Copy link
Member

I think initial page-specific suggestions are good, but other link variations should still maintain their suggestions — i.e. categories, tags, posts.

This PR:

CleanShot 2023-09-20 at 09 56 42

Trunk:

CleanShot 2023-09-20 at 09 55 45

@richtabor
Copy link
Member

Related: We should account for page suggestions on LinkControl generally next: #50884

@draganescu
Copy link
Contributor Author

Good catch @richtabor. So a better way of formulating the need is:

  • the initial suggestions should default to the variation of the navigation link in the navigation block

I'll rewrtite this PR with this goal.

@getdave
Copy link
Contributor

getdave commented Sep 20, 2023

  • the initial suggestions should default to the variation of the navigation link in the navigation block

Please can we try and make whatever we implement geared so that it's not specific to any block or WordPress? Whilst this function is part of core-data then component itself is block-editor and so as you know we need to avoid anything that couples to WP.

I think it could be formulated as:

"the initial suggestions should default to the type configured when calling the search handler"

🙏 Thank you

@getdave
Copy link
Contributor

getdave commented Sep 20, 2023

I think what I call default you call initial.

I think perhaps this is being lost in translation? 😄

The PR says "defaults suggestions in LinkUI to pages". To me this means: "this PR sets the default value for the suggestions in the Link UI to be pages".

Based on your comments, perhaps a more accurate wording could be: "This PR changes the default type for the initially shown suggestions to always be "Pages"?

Sorry if this sounds pedantic but I wouldn't want people to think this PR solves more than it actually intends to 😅

@richtabor
Copy link
Member

richtabor commented Sep 20, 2023

the initial suggestions should default to the variation of the navigation link in the navigation block

Isn't this already the case, for all other variations (related: #54668). I think it's just the custom link that needs the page suggestions (on this effort).

@draganescu
Copy link
Contributor Author

So, considering the way suggestions work:

  • the suggestions are coming from the same query as the results
  • if the query limits the results it will have the same effect on suggestions
  • if the query is empty suggestions will contain a bit of everything

For custom links the empty query makes for searching literally into any type of content. While this is expected in general for links it's questionable if for the navigation block it is expected (to see links to fonts or other types of media/attachments as a "menu" item).

To quote @getdave

"This PR changes the default type for the initially shown suggestions to always be "Pages"

... which is bad because @richtabor says other "types" should show suggestions that are conforming to their type (a category link should show category suggestions).

Therefore the idea would be to have pages suggested for custom links and page links in the navigation block, but custom links to still search in everything. For this the way suggestions work would need to be updated to support an optional different query for suggestions. As if the whole link component tree is not complicated enough as it is.

Another option would be to support another search query prop, which if it is undefined means the suggestions query is the same as the search query but without any search prop, and if it is set it is used for suggestions. I think this second option makes more sense given the current implementation.

@getdave
Copy link
Contributor

getdave commented Sep 28, 2023

The fetch handling method has a prop under searchOptions called isInitialSuggestions

Why don't we use that to provide a different query?

If that route isn't available then I guess we'll need a new prop but we really need to make every effort to avoid expanding the API of LinkControl.

@draganescu
Copy link
Contributor Author

draganescu commented Sep 28, 2023

@getdave that would make the type of isInitialSuggestions be Bool | Object. We may also want to make the default undefined?

Otherwise I have no problem reusing that, seems benign to me.

Edit: actually not really, isInitialSuggestions is set by the system if searchValue is empty. We also need to add the actual query for initial suggestions for the cases when we want different initial suggestions compared to search result suggestions.

@getdave
Copy link
Contributor

getdave commented Sep 28, 2023

@getdave that would make the type of isInitialSuggestions be Bool | Object. We may also want to make the default undefined?

Otherwise I have no problem reusing that, seems benign to me.

Edit: actually not really, isInitialSuggestions is set by the system if searchValue is empty. We also need to add the actual query for initial suggestions for the cases when we want different initial suggestions compared to search result suggestions.

I'd got for that additional API then 👍

@@ -44,7 +44,15 @@ export function getSuggestionsQuery( type, kind ) {
if ( kind === 'post-type' ) {
return { type: 'post', subtype: type };
}
return {};
return {
// for custom link which has no type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// for custom link which has no type
// for custom link which has no kind

Is it kind?

Copy link
Contributor Author

@draganescu draganescu Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's type. The switch is on type and the default is for no type.

@scruffian
Copy link
Contributor

Having spent a while looking at this previously I can see that this is a very elegant solution, well done!

Copy link
Contributor

@getdave getdave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on this. Thank you for continuing to wrangle it.

I like this PR because it has avoided bloating the API of LinkControl whilst still allowing us to achieve what we need in an way that is isolated to the Nav block but gives option for extension in the future 👍

I hope you don't mind but I've pushed a few changes:

  • added unit test coverage for changes to fetchLinkSuggestions
  • fixed potential bug with undefined values.
  • renamed the new option to initialSuggestionsSearchOptions for consistency.

I think we should also update the description of the PR to make sure it is current with what is going to be merged here. The main thing is making it clear that this changes only effects the Navigation Link block and not the entire editor (unless I misunderstood something?).

Other than that LGTM 🚀

@github-actions
Copy link

Flaky tests detected in 9bd8998.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6356477842
📝 Reported issues:

@draganescu
Copy link
Contributor Author

Updated the PR description.

@draganescu draganescu merged commit 3e260aa into trunk Oct 2, 2023
52 checks passed
@draganescu draganescu deleted the try/default-to-pages branch October 2, 2023 11:24
@github-actions github-actions bot added this to the Gutenberg 16.8 milestone Oct 2, 2023
@Mamaduka
Copy link
Member

Mamaduka commented Oct 2, 2023

Haven't we tried this approach before, but it got reverted eventually, or am I miss-remembering something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) Needs Design Feedback Needs general design feedback. [Type] Enhancement A suggestion for improvement.
Projects
Development

Successfully merging this pull request may close these issues.

Navigation Link: Prioritize pages in the Link Control suggestions
6 participants